{extend name="public/base"}

{block name="title"}修改域名的目录{/block}

{block name="main"}
<!--添加用户UI-->

<div class="layui-row">
  <div class="layui-col-md4 layui-col-md-offset4">
    <form action="{:url('/hostcat/'.$obj.id).'?host_id='.$host_id}" method="post" class="layui-form layui-form-pane">
      <input type="hidden" name="_method" value="put">
      <div class="layui-form-item" >
        <label for="name" class="layui-form-label">目录名称</label>
        <div class="layui-input-block">
          <input type="text"  required  value="{$obj.name}"  id="name" name="name" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item" >
        <label for="url" class="layui-form-label">目录url</label>
        <div class="layui-input-block">
          <input type="text"  required value="{$obj.url}"   id="url" name="url" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label for="img" class="layui-form-label">目录图片</label>
        <div class="layui-input-block">
          <button type="button" class="layui-btn layui-btn-fluid" id="test1">
            <i class="layui-icon">&#xe67c;</i>上传图片
            <input type="hidden" name="img" id="img">
          </button>
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-col-md12">
          <img src="{$obj.img}" width="100%" height="120px"  class="layui-upload-img" id="demo1" alt="这是广告图片">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">目录所属域名</label>
        <div class="layui-input-block">
          <select name="host_id" id="host_id" class="form-control w-50  col-form-label">
            {volist name="host" id="obj" }
            <option value="{$obj.id}" {$obj.id == $host_id ? 'selected' : ''}>{$obj.host}</option>
            {/volist}
          </select>
        </div>
      </div>
      <div class="layui-form-item">
        <a href="{:url('/hostcat/'.$host_id)}" class="layui-btn layui-btn-normal  layui-btn-sm"><i class="layui-icon layui-icon-left"></i>返回列表</a>
      </div>
      <div class="layui-form-item">
        <input type="hidden" value="{:token()}" name="__token__">
        <button class="layui-btn layui-btn-success layui-btn-fluid layui-btn-lg">提交修改</button>
      </div>
    </form>
  </div>
</div>
<script>
  layui.use(['upload','layer','jquery','form'], function(){
    var upload = layui.upload,
            layer = layui.layer,
            $=layui.$;

    //执行实例
    var uploadInst = upload.render({
      elem: '#test1' //绑定元素
      ,url: "{:url('index/upload')}" //上传接口
      ,field:'image'
      ,accept: 'image'
      ,acceptMime:'image/*'
      ,before:function (obj) {
        //预读本地文件示例，不支持ie8
        obj.preview(function(index, file, result){
          $('#demo1').attr('src', result); //图片链接（base64）
        });
        layer.msg('上传中', {icon: 16, time: 0});
      }
      ,done: function(res){
        //上传完毕回调
        if (res.code===200){
          layer.msg(res.msg,{
            icon:1
          })
          $('#img').val(res.path)
        }else{
          layer.msg(res.msg,{
            icon:2
          })
        }
      }
      ,error: function(){
        //请求异常回调
      }
    });
  });
</script>
{/block}